package com.tanhua.manager.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.manager.domain.AnalysisByDay;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @author liuyp
 * @date 2021/02/21
 */
public interface AnalysisMapper extends BaseMapper<AnalysisByDay> {
    /**
     * 统计 累计用户数量
     * @return 累计用户数量
     */
    @Select("SELECT SUM(num_registered) FROM tb_analysis_by_day")
    Long cumulativeUsers();

    /**
     * 统计 指定日期范围内的活跃用户数量
     * @param startDate 开始日期
     * @param endDate 结束日期
     * @return 活跃用户数量
     */
    @Select("SELECT SUM(num_active) FROM tb_analysis_by_day WHERE record_date BETWEEN #{startDate} AND #{endDate}")
    Long activeUsersByRangeDate(@Param("startDate") String startDate, @Param("endDate") String endDate);

    // @Select("SELECT * FROM tb_analysis_by_day WHERE record_date BETWEEN #{startDate} AND #{endDate}")
    // List<AnalysisByDay> findByDateRange(@Param("startDate") String startDate, @Param("endDate") String endDate);
}
